package com.coreJava.renwubianpai;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * 作者: LCG
 * 日期: 2020/2/10 00:12
 * 描述: 测试Thread
 */
public class TestThread {
    public static void main(String[] args) throws InterruptedException, ExecutionException {

        Thread t1=new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("====01");
            }
        });
        t1.start();
        t1.join();
        Thread t2=new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("====02");
            }
        });
        t2.start();
        t2.join();

        System.out.println("==========000000===========");

        //带返回值
        FutureTask<String> f1=new FutureTask<String>(new Callable<String>() {
            @Override
            public String call() throws Exception {
                Thread.sleep(5000);
                return "01";
            }
        });

        Thread th2=new Thread(f1);
        th2.start();

        System.out.println(f1.get());

    }
}
